﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PoemGame.Domain.GameAggregate;

namespace PoemGame.Repository.EF
{
    public class GameEntityTypeConfiguration : IEntityTypeConfiguration<Game>
    {
        public void Configure(EntityTypeBuilder<Game> builder)
        {
            builder.ToTable("Game");
            builder.HasKey(o => o.Id);

            builder.OwnsOne(o => o.GameType);


            builder.OwnsMany(typeof(PlayerInGame), "_players").ToTable("PlayerInGame").HasKey("Id");
            builder.OwnsMany(typeof(PlayRecord), "Records").ToTable("PlayRecord").HasKey("Id");

            builder.Ignore(o => o.PlayersInGame);
            builder.Ignore(o => o.PlayRecords);
        }
    }
}
